#include <stdio.h>
#include <memory.h>

bool hide[ 1001 ][ 1001 ], check[ 1001 ];
int match[ 1001 ], m, n;

bool dfs( int p )
{
    int i, t;
    for ( i = 0; i < n + m; i++ )
    {
        if ( hide[ i ][ p ] && !check[ i ] )
        {
            check[ i ] = true;
            t = match[ i ];
            match[ i ] = p;
            if ( t == -1 || dfs( t ) )
                return true;
            match[ i ] = t;
        }
    }
    return false;
}

int main( )
{
    int k, save, i, a, b;
    while ( scanf("%d", &k) != EOF && k )
    {
        scanf("%d%d", &m, &n);
        memset( hide, false, sizeof( hide ) );
        for ( i = 0; i < k; i++ )
        {
            scanf("%d%d", &a, &b);
            hide[ a - 1 ][ b + m - 1 ] = true;
        } 
        save = 0;
        memset( match, -1, sizeof( match ) );
        for ( i = 0; i < n + m; i++ )
        {
            memset( check, false, sizeof( check ) );
            if ( dfs( i ) )
                save++;
        }
        printf("%d\n", save);
    }
    return 0;
}
